// types/echarts.ts
import type { EChartsOption, ECharts, EChartsInitOpts } from 'echarts'
import type { Ref } from 'vue'

// 定义LoadingOptions类型，因为echarts模块没有直接导出
interface LoadingOptions {
  text?: string;
  color?: string;
  textColor?: string;
  maskColor?: string;
  zlevel?: number;
  fontStyle?: 'normal' | 'italic' | 'oblique';
  fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | number;
  fontFamily?: string;
  fontSize?: number;
  showSpinner?: boolean;
  spinnerRadius?: number;
  lineWidth?: number;
  fontSizeBase?: number;
}

export interface ChartProps {
  option: EChartsOption
  theme?: string | object
  initOptions?: EChartsInitOpts
  style?: Record<string, string | number>
  className?: string
  loading?: boolean
  loadingOptions?: LoadingOptions
  autoResize?: boolean
  showLoadingOnRefresh?: boolean
  manualUpdate?: boolean
  group?: string
  onChartReady?: (instance: ECharts) => void
  onEvents?: Record<string, (params: any) => void>
  updateOptions?: {
    notMerge?: boolean
    lazyUpdate?: boolean
  }
}

export interface UseEChartsReturn {
  chartRef: Ref<HTMLDivElement | undefined>
  echartsInstance: Ref<ECharts | undefined>
  initChart: () => Promise<void>
  updateChart: (option?: EChartsOption) => Promise<void>
  resizeChart: () => void
  disposeChart: () => void
  showLoading: (loadingOptions?: LoadingOptions) => void
  hideLoading: () => void
}